<script language="javascript" type="text/javascript">   
$(document).ready(function(){
    $("#submit_category").click(function(){
        add_category();
    });
});

function add_category(){
    if(Check_category())
    {
       _add_category();
    }
}

function Check_category(){
    if($("#category_name").val()=="")
    {
		$("#msg_category").html("错误：类别名为空");
        $("#category_name").focus();
        return false;
    }
    return true;
}

function _add_category(){
    $.ajax({
            type:"POST",
            url:"ajax/category/add",
            data:{name:$("#category_name").val()},
			dataType: "html",
            beforeSend:function(){$("#msg_category").html("添加中");},             
            success:function(data){
			   $("#msg_category").html(data);            
			},
			error:function(jqXHR, textStatus, errorThrown){
				$("#msg_category").html(jqXHR.responseText);
			},
         });
    }



</script>
<form id="inputForm" action="/admin/category/new" method="post" enctype="multipart/form-data">
      <div class="row clearfix">
        <label for="category_name">类别名:</label>
        <p><span>
          <input name="category_name" maxlength="100" id="category_name" class="inputs med required">
          </span><span id="NameError"></span></p>
      </div>
      <div class="row clearfix">
        <input type="button" name="submit_category" id="submit_category" class="submit" value="添加">
      </div>
	  <div id="msg_category"></div>
    </form>
